package com.yby.dome5;

public class Ticket {
    static int ticket = 100;//定义一个静态变量票数，初始值设为100
    private int tickets;
    static {
        System.out.println("总共还剩100张");
    }
    //定义一个方法代表售票，每次卖1张，售票后打印剩余总票数。
    public void salesTicket(){
        ticket --;
        System.out.println("总共还剩"+ticket+"张");
        if (ticket == 0){
            System.out.println("票已经卖完了");
            return;
        }
    }
    public void salesTicket(int tickets){
        this.tickets = tickets;
        ticket = ticket - tickets;
        System.out.println("总共还剩"+ticket+"张");
        if (ticket == 0) {
            System.out.println("票已经卖完了");
            return;
        }
    }
}
